package org.celery.modules.merchant.wrapper;

import org.celery.modules.merchant.service.IMerchantDeskService;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.celery.modules.merchant.entity.MerchantDesk;
import org.celery.modules.merchant.vo.MerchantDeskVO;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;

/**
 * 商户桌台表.包装类,返回视图层所需的字段
 *
 * @author Celery
 * @since 2021-11-07
 */
public class MerchantDeskWrapper extends BaseEntityWrapper<MerchantDesk, MerchantDeskVO>  {

    public static MerchantDeskWrapper build() {
        return new MerchantDeskWrapper();
    }

	@Override
	public MerchantDeskVO entityVO(MerchantDesk merchantDesk) {
		MerchantDeskVO merchantDeskVO = BeanUtil.copy(merchantDesk, MerchantDeskVO.class);
		IMerchantDeskService merchantDeskService = SpringUtil.getBean(IMerchantDeskService.class);

		if (Func.isNotEmpty(merchantDesk.getDeskCategoryId())) {
			merchantDeskVO.setDeskCategoryName(Func.join(merchantDeskService.getDeskCategoryName(merchantDesk.getDeskCategoryId())));
		}

		return merchantDeskVO;
	}

}
